package com.ihr360.job.core.repository.dao;

import com.ihr360.job.core.entity.JobExecution;
import com.ihr360.job.core.entity.StepExecution;
import com.ihr360.job.core.item.ExecutionContext;

import java.util.Collection;


/**
 * DAO interface for persisting and retrieving {@link ExecutionContext}s.
 *
 * @author Robert Kasanicky
 * @author David Turanski
 */
public interface ExecutionContextDao {

    /**
     * @param jobExecution
     * @return execution context associated with the given jobExecution
     */
    ExecutionContext getExecutionContext(JobExecution jobExecution);

    /**
     * @param stepExecution
     * @return execution context associated with the given stepExecution
     */
    ExecutionContext getExecutionContext(StepExecution stepExecution);

    /**
     * Persist the execution context associated with the given jobExecution,
     * persistent entry for the context should not exist yet.
     * @param jobExecution
     */
    void saveExecutionContext(final JobExecution jobExecution);

    /**
     * Persist the execution context associated with the given stepExecution,
     * persistent entry for the context should not exist yet.
     * @param stepExecution
     */
    void saveExecutionContext(final StepExecution stepExecution);

    /**
     * Persist the execution context associated with each stepExecution in a given collection,
     * persistent entry for the context should not exist yet.
     * @param stepExecutions
     */
    void saveExecutionContexts(final Collection<StepExecution> stepExecutions);

    /**
     * Persist the updates of execution context associated with the given
     * jobExecution. Persistent entry should already exist for this context.
     * @param jobExecution
     */
    void updateExecutionContext(final JobExecution jobExecution);

    /**
     * Persist the updates of execution context associated with the given
     * stepExecution. Persistent entry should already exist for this context.
     * @param stepExecution
     */
    void updateExecutionContext(final StepExecution stepExecution);
}
